package com.shijunhao.graduation.domain.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * @author: shijunhao
 * @date: 2022/3/2 15:01
 * @description:
 */
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(
            type = IdType.AUTO
    )
    @ApiModelProperty(value = "主键",example = "1")
    private Long id;

    @TableLogic
    @TableField(
            fill = FieldFill.INSERT,
            value = "is_deleted"
    )
    private Boolean deleted;

    @TableField(
            fill = FieldFill.INSERT
    )
    private Long createBy;

    @TableField(
            fill = FieldFill.INSERT
    )
    private Long updateBy;

    @TableField(
            fill = FieldFill.INSERT_UPDATE
    )
    private Date createDate;

    @TableField(
            fill = FieldFill.INSERT_UPDATE
    )
    private Date updateDate;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Boolean getDelete() {
        return deleted;
    }

    public void setDelete(Boolean deleted) {
        this.deleted = deleted;
    }

    public Long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Long createBy) {
        this.createBy = createBy;
    }

    public Long getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(Long updateBy) {
        this.updateBy = updateBy;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        } else if (o != null && this.getClass() == o.getClass()) {
            BaseEntity that = (BaseEntity)o;
            return Objects.equals(this.id, that.id);
        } else {
            return false;
        }
    }

    public int hashCode() {
        return Objects.hash(this.id);
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
}
